#pragma once
#include<iostream>
#include<string>
#include<ctime>
using std::string;
// [日志级别][时间][日志信息][错误文件名称][出错行数]
// 级别: INFO  正常的输出
//       WARNING   告警
//       ERROR  报错
//       FATAL  致命信息
#define INFO    1
#define WARNING 2
#define ERROR   3
#define FATAL   4

#define LOG(level, message) Log(#level, message, __FILE__, __LINE__)

void timeprin()  // 获取当前时间 yy - mm - dd 
{
    time_t ctime = time(nullptr);
    char myStr[25] = { 0 };
    struct tm *t = gmtime(&ctime);
	t->tm_hour += 8;//转为北京时间记的要加8
	std::string myFormat = "%Y-%m-%d:%H:%M:%S";
	strftime(myStr, sizeof(myStr), myFormat.c_str(), t);
	for (int i = 0; myStr[i]; ++i) {
		std::cout << myStr[i];
	}
}
void Log(string level,string message,string file_name,int line)
{
    std::cout << "[" << level << "] " << "["; 
    timeprin();
    std:: cout << "] " << "[" << message << "] " << "[" << file_name << "] " << "[" << line << "] " << std::endl;
}